import 'package:flutter/material.dart';
import 'package:top_foundation/utils/ex/image.dart';

import '../../../../helper/utils/util.dart';
import '../../model/msg.dart';
import '../../util/im_define.dart';
import '../index.dart';
import 'widgets.dart';

class IMCard extends IMCell {
  const IMCard({super.key, required super.md});
  @override
  Widget build(BuildContext context) {
    IMMsgCardModel m = md.msg as IMMsgCardModel;
    var contentW = IMDefineContentConfig.maxW;
    double _w() {
      return contentW;
    }

    double _h() {
      return 150.r;
    }

    return GetBuilder<ImController>(
        id: m.id,
        builder: (_) {
          return Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Padding(
                padding: EdgeInsets.fromLTRB(12.r, 10.r, 12.r, 0),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      m.title,
                      style: TextStyle(
                          color: const Color(0xff333333), fontSize: 16.sp),
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          m.des,
                          style: TextStyle(
                              color: const Color(0xff999999), fontSize: 13.sp),
                        ),
                        IImage.net(
                            url: m.image,
                            width: 60.r,
                            height: 60.r,
                            fit: BoxFit.contain),
                      ],
                    ),
                    Container(
                      height: 0.5,
                      margin: const EdgeInsets.only(top: 5),
                      color: const Color(0xffcdcdcd),
                    ),
                    Container(
                      padding: const EdgeInsets.symmetric(vertical: 5),
                      alignment: Alignment.centerLeft,
                      child: Row(
                        children: [
                          IImage.net(
                              url: m.sourceIcon, width: 16.r, height: 16.r),
                          const SizedBox(width: 5),
                          Text(
                            m.sourceName,
                            style: TextStyle(
                                color: const Color(0xff999999),
                                fontSize: 11.sp),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ],
          );
        });
  }
}
